package com.example.hyw.szysteam.presenter;

import com.example.hyw.szysteam.POJO.CLassMember;
import com.example.hyw.szysteam.POJO.HttpResult;
import com.example.hyw.szysteam.model.ClassModel;
import com.example.hyw.szysteam.view.ClassMemberFragment;

import java.util.ArrayList;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by HYW on 2018/6/8.
 */

public class ClassMemberPresenter {
    ClassModel classModel=new ClassModel();
    ClassMemberFragment classMemberFragment;

    public ClassMemberPresenter(ClassMemberFragment classMemberFragment) {
        this.classMemberFragment = classMemberFragment;
    }

    public void classMember(String classid){
        classModel.classmember(classid)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<HttpResult<ArrayList<CLassMember>>>() {
                    @Override
                    public void accept(HttpResult<ArrayList<CLassMember>> arrayListHttpResult) throws Exception {
                        ArrayList<CLassMember> arrayList=arrayListHttpResult.getContent();
                            classMemberFragment.initListView(arrayList);
                    }
                });
    }
}
